home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / Hack / Main.C < prev    next >
C/C++ Source or Header  |  1996-10-31  |  4KB  |  217 lines

  1. /* **** HBBS Door Code****************************************************** */
  2.  
  3. /*
  4.   Hack
  5.   ====
  6.  
  7.     This is called by frontend
  8.  
  9.   Version
  10.   =======
  11.  
  12.     1.0
  13.  
  14.   Options
  15.   =======
  16.  
  17.     N_ND->ActiveDoor->SystemOptions
  18.     -------------------------------
  19.  
  20.     none
  21.  
  22.     Command Line Arguments
  23.     ----------------------
  24.  
  25.     2  PSWD | LOCK | TIME
  26.  
  27.     3  <Username>
  28.  
  29.   ToDo
  30.   ====
  31.  
  32.     Finish It
  33.  
  34.  
  35. */
  36.  
  37. /* **** Includes *********************************************************** */
  38.  
  39. #include <exec/types.h>
  40. #include <exec/memory.h>
  41. #include <dos/dos.h>
  42. #include <clib/exec_protos.h>
  43. #include <clib/dos_protos.h>
  44. #include <clib/alib_protos.h>
  45.  
  46. #include <stdlib.h>
  47. #include <string.h>
  48. #include <stdio.h>
  49. #include <ctype.h>
  50. #include <time.h>
  51.  
  52. #include <HBBS/ANSI_Codes.h>
  53. #include <HBBS/Defines.h>
  54. #include <HBBS/Access.h>
  55. #include <HBBS/types.h>
  56. #include <HBBS/structures.h>
  57. #include <HBBS/hbbscommon_protos.h>
  58. #include <HBBS/hbbscommon_pragmas.h>
  59. #include <HBBS/Hbbsnode_protos.h>
  60. #include <HBBS/Hbbsnode_pragmas.h>
  61. #include <HBBS/release.h>
  62. char *versionstr="$VER: Hack "RELEASE_STR;
  63.  
  64. /* **** Variables ********************************************************** */
  65.  
  66.  
  67. struct Library *HBBSCommonBase  = NULL;
  68. struct Library *HBBSNodeBase    = NULL;
  69.  
  70. struct BBSGlobalData *BBSGlobal = NULL;
  71. struct NodeData *N_ND           = NULL;
  72. int    N_NodeNum                = -1;
  73. char   outstr[1024];
  74.  
  75. long __stack=16*1024; // increse this in 4k incrments if you suffer from
  76.                       // random/suprious crashings after or during the running
  77.                       // of your door.
  78.  
  79. int    gargc;         // these are just copies of main()'s argc and argv..
  80. char   **gargv;
  81.  
  82. /* **** Functions ********************************************************** */
  83.  
  84.  
  85. #ifdef __SASC
  86. int CXBRK(void) { return(0); }
  87. int _CXBRK(void) { return(0); }
  88. void chkabort(void) {}
  89. #endif
  90.  
  91. static VOID cleanup(ULONG num)
  92. {
  93.   if (HBBSNodeBase)
  94.   {
  95.     HBBS_CleanUpDoor();
  96.     CloseLibrary (HBBSNodeBase);
  97.   }
  98.  
  99.   if (HBBSCommonBase)
  100.   {
  101.     HBBS_CleanUpCommon();
  102.     CloseLibrary (HBBSCommonBase);
  103.   }
  104.  
  105.   if (num) printf("Door Error = %d\n",num);
  106.  
  107.   exit(0);
  108. }
  109.  
  110. static VOID init(char *name)
  111. {
  112.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  113.   {
  114.     cleanup(1);
  115.   }
  116.  
  117.   if (!(HBBS_InitCommon()))
  118.   {
  119.     cleanup(2);
  120.   }
  121.  
  122.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  123.   {
  124.     cleanup(3);
  125.   }
  126.  
  127.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  128.   {
  129.     cleanup(4);
  130.   }
  131.   SetProgramName(name);
  132. }
  133.  
  134. /* **** DoorMain *********************************************************** */
  135.  
  136. void DoorMain( void )
  137. {
  138.   int loop;
  139.   BOOL Done=FALSE;
  140.   if (gargc<4)
  141.   {
  142.     DOOR_PausePrompt("Not Enough Parameters Passed to HACK door!");
  143.   }
  144.   else
  145.   {
  146.     // Get the username from the parameters
  147.     outstr[0]=0;
  148.     for(loop=3;loop<gargc;loop++)
  149.     {
  150.       if (loop!=3) strcat(outstr," ");
  151.       strcat(outstr,gargv[loop]);
  152.     }
  153.  
  154.     DOOR_WriteText(ANSI_CLS);
  155.  
  156.     sprintf(outstr,"HACK_%s",gargv[2]);
  157.  
  158.     DOOR_DisplaySpecialScreen(outstr);
  159.  
  160.     DOOR_WriteText(ANSI_RESET ANSI_FG_YELLOW );
  161.  
  162.     while (N_ND->OnlineStatus==OS_ONLINE && !Done)
  163.     {
  164.       DOOR_MenuPrompt(ANSI_RESET "\r\nLeave a [C]omment, Page the [O]perator or [G]oodbye : ",' ');
  165.       strcpy(N_ND->CharsAllowed,"COGcog");
  166.  
  167.       if (IN_TIMEOUT==DOOR_GetLine(GL_IMMEDIATE|GL_USECHARS,0,1,30,NULL))
  168.       {
  169.         Done=TRUE;
  170.         DOOR_WriteText("Timeout!, bye!!\r\n");
  171.       }
  172.       if (N_ND->OnlineStatus==OS_ONLINE && !Done)
  173.       {
  174.         DOOR_WriteText(N_ND->CurrentLine);
  175.         DOOR_WriteText("\r\n");
  176.         switch (toupper(N_ND->CurrentLine[0]))
  177.         {
  178.           case 'C':
  179.             DOOR_UserDoor("C",NULL);
  180.             break;
  181.           case 'O':
  182.             DOOR_UserDoor("O",NULL);
  183.             break;
  184.           case 'G':
  185.             Done=TRUE;
  186.             break;
  187.         }
  188.       }
  189.     }
  190.     DOOR_DisplaySpecialScreen("HACK_BYE");
  191.   }
  192. }
  193.  
  194. int main(int argc,char **argv)
  195. {
  196.   gargc=argc;
  197.   gargv=argv;
  198.  
  199.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  200.   {
  201.     printf("Invalid/No Paramaters for door!\n");
  202.     exit (20);
  203.   }
  204.   init("Hack");
  205.  
  206.   if (BBSGlobal=HBBS_GimmeBBS())
  207.   {
  208.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  209.     {
  210.       DoorMain();
  211.     }
  212.   }
  213.   cleanup(0);
  214. }
  215.  
  216. /* **** End Of File ******************************************************** */
  217.